package com.briup.srms.sms.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.srms.sms.bean.extend.StudentDormitoryExtend;
import com.briup.srms.sms.service.IStudentDormitoryService;
import com.jacky.base.utils.Message;
import com.jacky.base.utils.MessageUtil;
import com.jacky.base.utils.PageVM;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @program: 杰普基础管理系统
 * @description: 学生宿舍控制器类
 * @author: charles
 * @create: 2020-12-27 17:22
 **/
@Api(description = "学生宿舍相关接口")
@Validated
@RestController
@RequestMapping("/studentDormitory")
public class StudentDormitoryController {
	
	@Autowired
	private IStudentDormitoryService sdService;
	
	@ApiOperation(value = "分页多条件获取数据学生宿舍预约信息")
	@GetMapping("pageQuery")
	@ApiImplicitParams({ 
		@ApiImplicitParam(name = "page", value = "当前页", required = true, paramType = "query"),
		@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"), 
		@ApiImplicitParam(name = "studentId", value = "学生编号", required = false, paramType = "query"),
		@ApiImplicitParam(name = "dormitoryTypeId", value = "宿舍类型编号", required = false, paramType = "query"),
	})
	public Message pageQuery(int page, int pageSize,Long studentId,Long dormitoryTypeId) {
		PageVM<StudentDormitoryExtend> pageVM = sdService.pageQuery(page, pageSize, studentId, dormitoryTypeId);
		return MessageUtil.success(pageVM);
	}
	
	@ApiOperation(value = "预约宿舍")
	@PostMapping("subscribeDormitory")
	public Message subscribeDormitory(long studentId,long dormitoryTypeId) {
		sdService.subscribeDormitory(studentId,dormitoryTypeId);
		return MessageUtil.success("预约成功！");
	}
}
